home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / Think-Pascal-7.0.cpt / THINK Pascal Interfaces / DatabaseAccess.p < prev    next >
Encoding:
Text File  |  1991-04-03  |  7.0 KB  |  271 lines  |  [TEXT/PJMM]

  1. {    This file has been processed by The THINK Pascal Source Converter, v1.1.    }
  2.  
  3. {}
  4. {}
  5. {Created: Monday, March 20, 1989 at 9:06 AM}
  6. {    DatabaseAccess.p}
  7. {    Pascal Interface to the Macintosh Libraries}
  8. {}
  9. {    Copyright Apple Computer, Inc.     1989-1991}
  10. {    All rights reserved}
  11. {}
  12. {}
  13.  
  14.  
  15. {$IFC UNDEFINED UsingIncludes}
  16. {$SETC UsingIncludes := 0}
  17. {$ENDC}
  18.  
  19.  
  20. unit DatabaseAccess;
  21. interface
  22.     uses
  23.         Types, OSUtils, Files, Resources;
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.     const
  39.  
  40. { error and status codes }
  41.         rcDBNull = -800;
  42.         rcDBValue = -801;
  43.         rcDBError = -802;
  44.         rcDBBadType = -803;
  45.         rcDBBreak = -804;
  46.         rcDBExec = -805;
  47.         rcDBBadSessID = -806;
  48.         rcDBBadSessNum = -807;        { bad session number for DBGetConnInfo }
  49.  
  50.         rcDBBadDDEV = -808;         { bad ddev specified on DBInit }
  51.  
  52.         rcDBAsyncNotSupp = -809;    { ddev does not support async calls }
  53.         rcDBBadAsyncPB = -810;        { tried to kill a bad pb }
  54.  
  55.         rcDBNoHandler = -811;        { no app handler for specified data type }
  56.  
  57.         rcDBWrongVersion = -812;    { incompatible versions }
  58.         rcDBPackNotInited = -813;    { attempt to call other routine before InitDBPack }
  59.  
  60. { messages for status functions for DBStartQuery }
  61.         kDBUpdateWind = 0;
  62.         kDBAboutToInit = 1;
  63.         kDBInitComplete = 2;
  64.         kDBSendComplete = 3;
  65.         kDBExecComplete = 4;
  66.         kDBStartQueryComplete = 5;
  67.  
  68. { messages for status functions for DBGetQueryResults }
  69.         kDBGetItemComplete = 6;
  70.         kDBGetQueryResultsComplete = 7;
  71.  
  72.         typeNone = 'none';
  73.         typeDate = 'date';
  74.         typeTime = 'time';
  75.         typeTimeStamp = 'tims';
  76.         typeDecimal = 'deci';
  77.         typeMoney = 'mone';
  78.         typeVChar = 'vcha';
  79.         typeVBin = 'vbin';
  80.         typeLChar = 'lcha';
  81.         typeLBin = 'lbin';
  82.         typeDiscard = 'disc';
  83.  
  84. { "dummy" types for DBResultsToText }
  85.         typeUnknown = 'unkn';
  86.         typeColBreak = 'colb';
  87.         typeRowBreak = 'rowb';
  88.  
  89. { pass this in to DBGetItem for any data type }
  90.         typeAnyType = 0;
  91.  
  92. { infinite timeout value for DBGetItem }
  93.         kDBWaitForever = -1;
  94.  
  95. { flags for DBGetItem }
  96.         kDBLastColFlag = $0001;
  97.         kDBNullFlag = $0004;
  98.  
  99.     type
  100.  
  101.         DBType = OSType;
  102.  
  103. { structure for asynchronous parameter block }
  104.         DBAsyncParamBlockRec = record
  105.                 completionProc: ProcPtr;    { pointer to completion routine }
  106.                 result: OSErr;        { result of call }
  107.                 userRef: LONGINT;    { for application's use }
  108.                 ddevRef: LONGINT;    { for ddev's use }
  109.                 reserved: LONGINT;    { for internal use }
  110.             end;
  111.  
  112.         DBAsyncParmBlkPtr = ^DBAsyncParamBlockRec;
  113.  
  114. { structure for resource list in QueryRecord }
  115.  
  116.         ResListElem = record
  117.                 theType: ResType;
  118.                 id: INTEGER;
  119.             end;
  120.  
  121.         ResListPtr = ^ResListArray;
  122.         ResListHandle = ^ResListPtr;
  123.         ResListArray = array[0..255] of ResListElem;
  124.  
  125. { structure for query list in QueryRecord }
  126.  
  127.         QueryListPtr = ^QueryArray;
  128.         QueryListHandle = ^QueryListPtr;
  129.         QueryArray = array[0..255] of Handle;
  130.  
  131.         QueryPtr = ^QueryRecord;
  132.         QueryHandle = ^QueryPtr;
  133.         QueryRecord = record
  134.                 version: INTEGER;            { version }
  135.                 id: INTEGER;            { id of 'qrsc' this came from }
  136.                 queryProc: Handle;             { handle to query def proc }
  137.                 ddevName: Str63;                { ddev name }
  138.                 host: Str255;             { host name }
  139.                 user: Str255;             { user name }
  140.                 password: Str255;             { password }
  141.                 connStr: Str255;             { connection string }
  142.                 currQuery: INTEGER;            { index of current query }
  143.                 numQueries: INTEGER;            { number of queries in list }
  144.                 queryList: QueryListHandle;    { handle to array of handles to text }
  145.                 numRes: INTEGER;            { number of resources in list }
  146.                 resList: ResListHandle;        { handle to array of resource list elements }
  147.                 dataHandle: Handle;             { for use by query def proc }
  148.                 refCon: LONGINT;            { for use by application }
  149.             end;
  150.  
  151. { structure of column types array in ResultsRecord }
  152.  
  153.         ColTypesPtr = ^ColTypesArray;
  154.         ColTypesHandle = ^ColTypesPtr;
  155.         ColTypesArray = array[0..255] of DBType;
  156.  
  157. { structure for column info in ResultsRecord }
  158.  
  159.         DBColInfoRecord = record
  160.                 len: INTEGER;
  161.                 places: INTEGER;
  162.                 flags: INTEGER;
  163.             end;
  164.  
  165.         ColInfoPtr = ^ColInfoArray;
  166.         ColInfoHandle = ^ColInfoPtr;
  167.         ColInfoArray = array[0..255] of DBColInfoRecord;
  168.  
  169.         ResultsRecord = record
  170.                 numRows: INTEGER;            { number of rows in result }
  171.                 numCols: INTEGER;            { number of columns per row }
  172.                 colTypes: ColTypesHandle;     { data type array }
  173.                 colData: Handle;             { actual results }
  174.                 colInfo: ColInfoHandle;         { DBColInfoRecord array }
  175.             end;
  176.  
  177.     function InitDBPack: OSErr;
  178.     inline
  179.         $3F3C, $0004, $303C, $0100, $A82F;
  180.  
  181.     function DBInit (var sessID: LONGINT; ddevName: Str63; host, user, passwd, connStr: Str255; asyncPB: DBAsyncParmBlkPtr): OSErr;
  182.     inline
  183.         $303C, $0E02, $A82F;
  184.  
  185.     function DBEnd (sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  186.     inline
  187.         $303C, $0403, $A82F;
  188.  
  189.     function DBGetConnInfo (sessID: LONGINT; sessNum: INTEGER; var returnedID, version: LONGINT; var ddevName: Str63; var host, user, network, connStr: Str255; var start: LONGINT; var state: OSErr; asyncPB: DBAsyncParmBlkPtr): OSErr;
  190.     inline
  191.         $303C, $1704, $A82F;
  192.  
  193.     function DBGetSessionNum (sessID: LONGINT; var sessNum: INTEGER; asyncPB: DBAsyncParmBlkPtr): OSErr;
  194.     inline
  195.         $303C, $0605, $A82F;
  196.  
  197.     function DBSend (sessID: LONGINT; text: Ptr; len: INTEGER; asyncPB: DBAsyncParmBlkPtr): OSErr;
  198.     inline
  199.         $303C, $0706, $A82F;
  200.  
  201.     function DBSendItem (sessID: LONGINT; dataType: DBType; len, places, flags: INTEGER; buffer: Ptr; asyncPB: DBAsyncParmBlkPtr): OSErr;
  202.     inline
  203.         $303C, $0B07, $A82F;
  204.  
  205.     function DBExec (sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  206.     inline
  207.         $303C, $0408, $A82F;
  208.  
  209.     function DBState (sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  210.     inline
  211.         $303C, $0409, $A82F;
  212.  
  213.     function DBGetErr (sessID: LONGINT; var err1, err2: LONGINT; var item1, item2, errorMsg: Str255; asyncPB: DBAsyncParmBlkPtr): OSErr;
  214.     inline
  215.         $303C, $0E0A, $A82F;
  216.  
  217.     function DBBreak (sessID: LONGINT; abort: BOOLEAN; asyncPB: DBAsyncParmBlkPtr): OSErr;
  218.     inline
  219.         $303C, $050B, $A82F;
  220.  
  221.     function DBGetItem (sessID, timeout: LONGINT; var dataType: DBType; var len, places, flags: INTEGER; buffer: Ptr; asyncPB: DBAsyncParmBlkPtr): OSErr;
  222.     inline
  223.         $303C, $100C, $A82F;
  224.  
  225.     function DBUnGetItem (sessID: LONGINT; asyncPB: DBAsyncParmBlkPtr): OSErr;
  226.     inline
  227.         $303C, $040D, $A82F;
  228.  
  229.     function DBKill (asyncPB: DBAsyncParmBlkPtr): OSErr;
  230.     inline
  231.         $303C, $020E, $A82F;
  232.  
  233.     function DBGetNewQuery (queryID: INTEGER; var query: QueryHandle): OSErr;
  234.     inline
  235.         $303C, $030F, $A82F;
  236.  
  237.     function DBDisposeQuery (query: QueryHandle): OSErr;
  238.     inline
  239.         $303C, $0210, $A82F;
  240.  
  241.     function DBStartQuery (var sessID: LONGINT; query: QueryHandle; statusProc: ProcPtr; asyncPB: DBAsyncParmBlkPtr): OSErr;
  242.     inline
  243.         $303C, $0811, $A82F;
  244.  
  245.     function DBGetQueryResults (sessID: LONGINT; var results: ResultsRecord; timeout: LONGINT; statusProc: ProcPtr; asyncPB: DBAsyncParmBlkPtr): OSErr;
  246.     inline
  247.         $303C, $0A12, $A82F;
  248.  
  249.     function DBResultsToText (results: ResultsRecord; var theText: Handle): OSErr;
  250.     inline
  251.         $303C, $0413, $A82F;
  252.  
  253.     function DBInstallResultHandler (dataType: DBType; theHandler: ProcPtr; isSysHandler: BOOLEAN): OSErr;
  254.     inline
  255.         $303C, $0514, $A82F;
  256.  
  257.     function DBRemoveResultHandler (dataType: DBType): OSErr;
  258.     inline
  259.         $303C, $0215, $A82F;
  260.  
  261.     function DBGetResultHandler (dataType: DBType; var theHandler: ProcPtr; getSysHandler: BOOLEAN): OSErr;
  262.     inline
  263.         $303C, $0516, $A82F;
  264.  
  265.     { UsingDatabaseAccess }
  266.  
  267.  
  268. implementation
  269. end.
  270.  
  271.